
GamePlayCtrl = {};
local this = GamePlayCtrl;

local name;
--构建函数--
function GamePlayCtrl.New()
	logWarn("GamePlayCtrl.New--->>");
	name = "GamePlay";
	return this;
end

function GamePlayCtrl.Awake()
	logWarn("GamePlayCtrl.Awake--->>");
	panelMgr:CreatePanel(name, this.OnCreate);
	
end

--启动事件--
function GamePlayCtrl.OnCreate(obj)
	Game.UpdateCurrentPanel(name);
	local GamePlay = obj:GetComponent('LuaBehaviour');
	GamePlay:AddClick(GamePlayPanel.RestartBtn,this.RestartBtnOnClick);
	GamePlay:AddClick(GamePlayPanel.QuitBtn,this.QuitBtnOnClick);
	GamePlay:AddClick(GamePlayPanel.QuitViewBtn,this.QuitViewBtnOnClick);

	this.InitScoreboard();
	FrameMgr:StartGame();
	logWarn("Start lua--->>"..obj.name);
end

function GamePlayCtrl.InitScoreboard()
	local players = NetData:GetPlayerList();
	for i=0,players.Length-1 do
		logError(tostring(RoleType.IntToEnum(players[i].heroid)));
	   GamePlayPanel.Scoreboard:Find(tostring(RoleType.IntToEnum(players[i].heroid))).gameObject:SetActive(true);
    end
end


function GamePlayCtrl.RestartBtnOnClick(go)
	FrameMgr:QuitRoom();
	this.Push();
end

function GamePlayCtrl.QuitBtnOnClick(go)
	GamePlayPanel.GameOver:DOScaleY(0,0.15);
	GamePlayPanel.QuitViewBtn:SetActive(true);
end

function GamePlayCtrl.QuitViewBtnOnClick(go)
	this.RestartBtnOnClick(go);
end

function GamePlayCtrl.GameOver(str)
	GamePlayPanel.ResultText.text = str;
	 GamePlayPanel.GameOver:DOScaleY(1,0.15);
end


function GamePlayCtrl.Push()
	--Game.CreatePanel(CtrlNames.GameLoading);
	ViewMgr:LoadMainScene();
end

